import { FormProps, FormSchema } from '@/components/Table'
import { BasicColumn } from '@/components/Table/src/types/table'
import { orderStatusArr, tryFlagArr } from '@/utils/typeMenu'
import dayjs, { Dayjs } from 'dayjs'

// 订单列表
export function getOrderBasicColumns(): BasicColumn[] {
  return [
    {
      title: '订单编号',
      dataIndex: 'orderNo'
    },
    {
      title: '企业名称',
      customEllipsis: true,
      width: 240,
      dataIndex: 'enterprise'
    },
    {
      title: '套餐名称',
      width: 160,
      customEllipsis: true,
      dataIndex: 'packageName'
    },
    {
      title: '订单金额',
      width: 140,
      align: 'right',
      dataIndex: 'orderAmt'
    },
    {
      title: '渠道名称',
      width: 140,
      customEllipsis: true,
      dataIndex: 'channelName'
    },
    // {
    //   title: '缴款类型',
    //   width: 140,
    //   dataIndex: 'payType'
    // },
    {
      title: '缴款方式',
      width: 140,
      dataIndex: 'payMethod'
    },
    {
      title: '下单时间',
      width: 140,
      dataIndex: 'createTime'
    },
    {
      title: '订单状态',
      width: 140,
      dataIndex: 'orderStatus'
    },
    {
      title: '开票状态',
      width: 100,
      dataIndex: 'invoiceStatus'
    },
    {
      title: '订单属性',
      width: 80,
      dataIndex: 'tryFlag'
    },
    {
      title: '备注',
      width: 140,
      customEllipsis: true,
      dataIndex: 'remark'
    },
    {
      title: '操作',
      width: 146,
      fixed: 'right',
      dataIndex: 'operate'
    }
  ]
}

export function getSearchFormConfig(): Partial<FormProps> {
  return {
    labelWidth: 80,
    baseColProps: {
      lg: 10,
      xl: 8,
      xxl: 6
    },
    schemas: [
      {
        field: 'enterprise',
        label: '企业名称',
        component: 'Input'
      },
      {
        field: 'orderStatus',
        label: '订单状态',
        component: 'Select',
        componentProps: {
          options: orderStatusArr
        }
      },
      {
        field: '[createTimeStart, createTimeEnd]',
        component: 'RangePicker',
        label: '下单时间',
        componentProps: {
          valueFormat: 'YYYY-MM-DD',
          disabledDate: (current: Dayjs) => {
            return current && current.isAfter(dayjs().startOf('day'), 'day')
          }
        }
      },
      {
        field: 'orderNo',
        label: '订单编号',
        component: 'Input'
      },
      {
        field: 'packageName',
        label: '套餐名称',
        component: 'Input'
      },
      {
        field: 'tryFlag',
        label: '订单属性',
        component: 'Select',
        componentProps: {
          options: tryFlagArr
        }
      },
      {
        field: 'channelCode',
        label: '渠道名称',
        component: 'TreeSelect',
        slot: 'channelCode'
      }
    ]
  }
}
